package com.caochenlei.principle.interfaceSegregation;

public class InterfaceSegregation2 {
    //接口Interface1
    interface Interface1 {
        void operation1();
    }

    //接口Interface2
    interface Interface2 {
        void operation2();
    }

    //接口Interface3
    interface Interface3 {
        void operation3();
    }

    //实现类A用Interface1中的operation1和Interface2中的operation2
    class A implements Interface1, Interface2 {
        @Override
        public void operation1() {
            System.out.println("A 实现了 operation1...");
        }

        @Override
        public void operation2() {
            System.out.println("A 实现了 operation2...");
        }
    }

    //实现类B用Interface1中的operation1和Interface3中的operation3
    class B implements Interface1, Interface3 {
        @Override
        public void operation1() {
            System.out.println("B 实现了 operation1...");
        }

        @Override
        public void operation3() {
            System.out.println("B 实现了 operation3...");
        }
    }
}

